#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:10_calculate.py
# author:张世航
# datetime:2024/10/31 19:24
# software: PyCharm
"""
this is function  description 
"""
# import module your need

# 10 编写一个函数cacluate, 可以实现2个数的运算(加,减 乘,除)

def calculate(a, b, operation):
    if operation == 'add':
        return a + b
    elif operation == 'subtract':
        return a - b
    elif operation == 'multiply':
        return a * b
    elif operation == 'divide':
        if b != 0:
            return a / b
        else:
            return "除数不能为零"
    else:
        return "无效的操作"

# 用户输入
num1 = float(input("请输入第一个数字："))
num2 = float(input("请输入第二个数字："))
operation = input("请输入操作（add, subtract, multiply, divide）：")
result = calculate(num1, num2, operation)
print("结果:", result)